package ar.edu.unq.wannaplay.utils;

import java.util.LinkedList;
import java.util.List;

import ar.edu.unq.wannaplay.dtos.DTO;

public class DTOHelper<REAL, theDTO> {

    public List<REAL> fromDtos(final List<DTO<REAL>> dtos) {
        List<REAL> resultList = new LinkedList<REAL>();
        for (DTO<REAL> currentDto : dtos) {
            resultList.add(currentDto.fromDto());
        }
        return resultList;
    }

    public List<theDTO> toDtos(final List<REAL> objects, final Service<REAL, theDTO> service) {
        List<theDTO> dtos = new LinkedList<theDTO>();
        for (REAL current : objects) {
            dtos.add(service.toDto(current));
        }
        return dtos;
    }
}
